<%@Page Language="VB"%>
<%@Import Namespace="System.Xml" %>
<%@Import Namespace="System.Xml.Xsl" %>
<html><head>
<title>Transforming an XML document using the XSLTransform object</title>
</head>
<body bgcolor="#ffffff">
<span class="heading">Transforming an XML document using the XSLTransform object</span><hr />

Using XML document file:
<b><span id="outXMLURL" runat="server"></span></b><br />
Loaded XSL stylesheet file:
<b><span id="outXSLURL" runat="server"></span></b><br />
Written new HTML disk file:
<b><span id="outHTMLURL" runat="server"></span></b><br />
<div id="outError" runat="server">&nbsp;</div>
<div id="outResults" runat="server"></div>
<script language="vb" runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
   'create physical path to booklist sample files (in same folder as ASPX page)
   Dim strCurrentPath As String = Request.PhysicalPath
   Dim strXMLPath As String = Left(strCurrentPath, InStrRev(strCurrentPath, "\")) & "booklist.xml"
   Dim strXSLPath As String = Left(strCurrentPath, InStrRev(strCurrentPath, "\")) & "booklist.xsl"
   Dim strHTMLPath As String = Left(strCurrentPath, InStrRev(strCurrentPath, "\")) & "booklist.html"

   outXMLURL.InnerHtml = "<a href=""" & strXMLPath & """>" & strXMLPath & "</a>"
   Try
      Dim objTransform As New XslTransform()
      objTransform.Load(strXSLPath)
      outXSLURL.InnerHtml = "<a href=""" & strXSLPath & """>" & strXSLPath & "</a>"
      objTransform.Transform(strXMLPath, strHTMLPath)
      outHTMLURL.InnerHtml = "<a href=""" & strHTMLPath & """>" & strHTMLPath & "</a>"
   Catch objError As Exception
      outError.innerHTML = "<b>* Error while accessing document</b>.<br />" _
          & objError.Message & "<br />" & objError.Source
      Exit Sub 

   End Try

End Sub
</script>
</body>
</html>

